package br.com.emefs1.ftgourmet.fragment;

import java.util.Locale;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import br.com.emefs1.ftgourmet.R;
import br.com.emefs1.ftgourmet.enu.EnumCategoria;

public class FragmentCategory extends Fragment {

	public final String ARG_CATEGORY_NUMBER = "category_number";

	public FragmentCategory() {

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View rootView = inflater.inflate(R.layout.list_fragment1, container,
				false);

		int i = getArguments().getInt(ARG_CATEGORY_NUMBER);
		String categorias = getResources().getStringArray(
				R.array.category_array)[i];
		String categoria = EnumCategoria.getByCodigo(categorias)
				.getLabelImagem();

		int imageId = getResources().getIdentifier(
				categoria.toLowerCase(Locale.getDefault()), "drawable",
				getActivity().getPackageName());
		((ImageView) rootView.findViewById(R.id.image_icon))
				.setImageResource(imageId);
		getActivity().setTitle(categorias);

		return rootView;
	}

}